<?php
namespace Home\Controller;
use Think\Controller;
class AnswerController extends CommonController {
    public function post(){
    	$data = I('post.');
    	$data['uid'] = $_SESSION['id'];
    	$data['create_time'] = time();

    	$res = M('answer')->add($data);

    	if($res){
    		$sql = "select t1.*,t2.nikename,t2.face from answer t1 left join user t2 on t1.uid=t2.id where t1.id='{$res}'";
    		$data = M()->query($sql);
    		$data = current($data);
    		$data['content'] = htmlspecialchars_decode($data['content']);
    		$data['create_time'] = getFormate($data['create_time']);
    		$arr = array(
             'error'=>'0',
             'info'=>'回复成功',
             'data'=>$data
             );
    		echo json_encode($arr);
    	}else{
    		$arr = array(
             'error'=>'1',
             'info'=>'回复失败，可能人品问题',
             );
    		echo json_encode($arr);
    	}
    }
}